package main

import (
	"fmt"
	"net/http"
	"strings"
)

func sendSMS(appName string, phoneNo string, otp string, sendType string, device_model string, cfg Config) error {
	url := "http://" + cfg.Sms_server + ":" + cfg.Sms_port
	url += cfg.Para0
	url += phoneNo
	url += cfg.Para1
	if sendType == "otp_link" {
		if device_model == "IOS" {
			url += appName
			url += "%40%23"
			url += otp
			url += cfg.Para2_1
		} else {
			url += otp
			url += cfg.Para2_2
		}

	} else {
		url += otp
		url += cfg.Para2
	}
	url += cfg.Para3

	url = strings.Replace(url, "\\", "", -1)
	url = strings.Replace(url, "@#", "%40%23", -1)

	fmt.Println("url ===== ", url, " =======")
	body, err := http.Get(url)
	if err != nil {
		fmt.Println(err)
		return err
	} else {
		fmt.Println(body)
	}
	return nil
}
